package iterator.source;

import java.util.ArrayList;
import java.util.List;

/**
 * 相当于Collection的具体实现类
 * @author cheng:
 * @date 2019/4/19 19:16
 */
public class ConcreteAggregate implements Iterable{

    private List<Object> items = new ArrayList<>();

    @Override
    public Iterator createIterator() {
        return new ConcreteIterator(this);
    }

    public int size(){
        return items.size();
    }

    public Object get(int index){
        return items.get(index);
    }

    public void set(Object o){
        items.add(o);
    }

    public void set(Object o, int index){
        items.add(index, o);
    }
}
